var token_tdt = '067998e486ea7ea61c91442ec719e8b3';

export var vecUrl = `http://t0.tianditu.com/vec_w/wmts?tk=${token_tdt}`;
export var cvaUrl = `http://t0.tianditu.com/cva_w/wmts?tk=${token_tdt}`;
export var satUrl = `http://t0.tianditu.com/img_w/wmts?tk=${token_tdt}`;
export var terUrl = `http://t0.tianditu.com/ter_w/wmts?tk=${token_tdt}`;
var sdvecUrl = "http://59.206.217.2:800/tileservice/SDPubMap?";
var sdsatUrl = "http://59.206.217.2:800/tileservice/SDRasterPubMap?";

export let baseurl =
  "&SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&STYLE=default&TILEMATRIXSET=w&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=tiles&LAYER=";
let sdbaseurl =
  "SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&STYLE=default&TILEMATRIXSET=raster&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=image/jpeg&LAYER=";

var tdtVec = {
  type: "raster",
  tiles: [vecUrl + baseurl + "vec"],
  tileSize: 256,
};
var tdtSat = {
  type: "raster",
  tiles: [satUrl + baseurl + "img"],
  tileSize: 256,
};
var tdtTer = {
  type: "raster",
  tiles: [terUrl + baseurl + "ter"],
  tileSize: 256,
};
var tdtCva = {
  type: "raster",
  tiles: [cvaUrl + baseurl + "cva"],
  tileSize: 256,
};
var sdtdtVec = {
  type: "raster",
  tiles: [sdvecUrl + sdbaseurl + "SDPubMap"],
  tileSize: 256,
};
var sdtdtSat = {
  type: "raster",
  tiles: [sdsatUrl + sdbaseurl + "SDRasterPubMap"],
  tileSize: 256,
};
function TileMap(raster, cav) {
  return {
    version: 8,
    sources: {
      "raster-tiles": {
        tiles: raster,
        type: "raster",
        tileSize: 256,
      },
      "cav-tiles": {
        tiles: cav,
        type: "raster",
        tileSize: 256,
      },
    },
    // glyphs: "mapbox://fonts/mapbox/{fontstack}/{range}.pbf",
    // "glyphs": `http://${ipapi}/mapboxfont/{fontstack}/{range}.pbf`,
    // sprite: "http://localhost:3000/lib/sprite",
    // sprite: "mapbox://sprites/mapbox/street-v11",
    layers: [
      {
        id: "raster-tiles",
        type: "raster",
        source: "raster-tiles",
        minzoom: 0,
        maxzoom: 22,
      },
      {
        id: "cav-tiles",
        type: "raster",
        source: "cav-tiles",
        minzoom: 0,
        maxzoom: 22,
      },
    ],
  };
}

export var basemaps = {
  tdtVec: {
    name: "天地图街道",
    value: TileMap(tdtVec.tiles, tdtCva.tiles),
  },
  tdtSat: {
    name: "天地图影像",
    value: TileMap(tdtSat.tiles, tdtCva.tiles),
  },
  tdtTer: {
    name: "天地图地形",
    value: TileMap(tdtTer.tiles, tdtCva.tiles),
  },
  // sdtdtVec: {
  //   name: "山东天地图街道",
  //   value: TileMap(sdtdtVec.tiles, tdtCva.tiles),
  // },
  // sdtdtSat: {
  //   name: "山东天地图影像",
  //   value: TileMap(sdtdtSat.tiles, tdtCva.tiles),
  // },
  // mapboxDark: { name: "MapBox黑色", value: "mapbox://styles/mapbox/dark-v10" },
  // mapboxStreet: {
  //   name: "MapBox街道",
  //   value: "mapbox://styles/mapbox/streets-v11",
  // },
  // mapboxOutDoor: {
  //   name: "MapBox户外",
  //   value: "mapbox://styles/mapbox/outdoors-v11",
  // },
  // mapboxLight: {
  //   name: "MapBox轻量",
  //   value: "mapbox://styles/mapbox/light-v10",
  // },
  // mapboxSat: {
  //   name: "MapBox卫星",
  //   value: "mapbox://styles/mapbox/satellite-v9",
  // },
  // mapboxSatStreet: {
  //   name: "MapBox卫星街道",
  //   value: "mapbox://styles/mapbox/satellite-streets-v11",
  // },
  // mapboxNight: {
  //   name: "MapBox夜晚",
  //   value: "mapbox://styles/mapbox/navigation-night-v1",
  // },
  // mapboxDay: {
  //   name: "MapBox白天",
  //   value: "mapbox://styles/mapbox/navigation-day-v1",
  // },
  // blank: {
  //   name: "纯色底图",
  //   value: {
  //     version: 8,
  //     name: "BlankMap",
  //     glyphs: "mapbox://fonts/mapbox/{fontstack}/{range}.pbf",
  //     sources: {},
  //     layers: [
  //       {
  //         id: "background",
  //         type: "background",
  //         paint: { "background-color": "#08294A" } /* 背景颜色 */,
  //       },
  //     ],
  //   },
  // },
  // osm:{name:'open street map',value:osmtileaddr},
};

export let basemapsx = {
  tdtVec:basemaps.tdtVec,
  tdtSat:basemaps.tdtSat,
  tdtTer:basemaps.tdtTer,
  // osm:basemaps.osm,
  // google:{name:'谷歌街道',value:googlesataddr.replace('{subDomain}','mt2')},
}